<!DOCTYPE html>
<html>
<head>
    <title>Physics Diagram</title>
</head>
<body>
<canvas id="physicsCanvas" width="400" height="450"></canvas>
<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // White background
    ctx.fillStyle = "white";
    ctx.fillRect(0, 0, canvas.width, canvas.height);

    // General drawing styles
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;

    // Define coordinates and dimensions
    const x_pivot = 200;
    const y_pivot = 60;
    const bar_length_L = 250;
    const impulse_dist_a = 150;
    const bar_width = 12;

    // Draw the fixed support at the top
    const support_width = 120;
    ctx.beginPath();
    ctx.moveTo(x_pivot - support_width / 2, y_pivot);
    ctx.lineTo(x_pivot + support_width / 2, y_pivot);
    ctx.stroke();

    // Draw hatching for the support
    ctx.save();
    ctx.lineWidth = 1;
    for (let i = 0; i < support_width; i += 10) {
        ctx.beginPath();
        ctx.moveTo(x_pivot - support_width / 2 + i, y_pivot);
        ctx.lineTo(x_pivot - support_width / 2 + i - 10, y_pivot - 10);
        ctx.stroke();
    }
    ctx.restore(); // Restore line width

    // Draw the vertical bar
    ctx.beginPath();
    ctx.rect(x_pivot - bar_width / 2, y_pivot, bar_width, bar_length_L);
    ctx.stroke();

    // --- Dimensions and Forces ---

    // Dimension L on the right
    const dim_L_x = x_pivot + 80;
    ctx.beginPath();
    ctx.moveTo(dim_L_x, y_pivot);
    ctx.lineTo(dim_L_x, y_pivot + bar_length_L);
    // Ticks for L
    ctx.moveTo(dim_L_x - 5, y_pivot);
    ctx.lineTo(dim_L_x + 5, y_pivot);
    ctx.moveTo(dim_L_x - 5, y_pivot + bar_length_L);
    ctx.lineTo(dim_L_x + 5, y_pivot + bar_length_L);
    ctx.stroke();

    // Dimension 'a' and Impulse 'J' on the left
    const dim_a_x = x_pivot - 80;
    const y_impulse = y_pivot + impulse_dist_a;
    
    // Dimension 'a' line
    ctx.beginPath();
    ctx.moveTo(dim_a_x, y_pivot);
    ctx.lineTo(dim_a_x, y_impulse);
    // Top tick for 'a'
    ctx.moveTo(dim_a_x - 5, y_pivot);
    ctx.lineTo(dim_a_x + 5, y_pivot);
    // Bottom tick for 'a'
    ctx.moveTo(dim_a_x - 5, y_impulse);
    ctx.lineTo(dim_a_x + 5, y_impulse);
    ctx.stroke();

    // Impulse arrow 'J' starting from the 'a' dimension line
    const arrow_end_x = x_pivot - bar_width / 2;
    ctx.beginPath();
    ctx.moveTo(dim_a_x, y_impulse);
    ctx.lineTo(arrow_end_x, y_impulse);
    // Arrowhead
    ctx.moveTo(arrow_end_x, y_impulse);
    ctx.lineTo(arrow_end_x - 12, y_impulse - 6);
    ctx.moveTo(arrow_end_x, y_impulse);
    ctx.lineTo(arrow_end_x - 12, y_impulse + 6);
    ctx.stroke();

    // --- Labels ---
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';

    // Label A at the pivot
    ctx.font = '22px serif';
    ctx.fillText('A', x_pivot + 20, y_pivot - 15);

    // Label L
    ctx.fillText('L', dim_L_x + 20, y_pivot + bar_length_L / 2);

    // Label a
    ctx.fillText('a', dim_a_x - 20, y_pivot + impulse_dist_a / 2);

    // Label J
    ctx.font = 'italic 24px serif';
    ctx.fillText('J', dim_a_x - 45, y_impulse);

    // Label B on the bar
    ctx.font = '22px serif';
    ctx.fillText('B', x_pivot + bar_width/2 + 20, y_impulse + 25);
    
    // Figure caption
    ctx.font = 'bold 20px serif';
    ctx.fillText('Fig. 1.131.', x_pivot, y_pivot + bar_length_L + 70);

</script>
</body>
</html>